<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>CKEDITOR.editor</title>
	<link rel="stylesheet" type="text/css" href="../test.css" />
	<script type="text/javascript" src="../../ckeditor.js"></script>
	<script type="text/javascript" src="../test.js"></script>
	<script type="text/javascript">
	//<![CDATA[

// Disable 'scayt' plugin due to it may alter editor config after initialized.
CKEDITOR.config.removePlugins = 'scayt';

CKEDITOR.test.addTestCase( (function()
{
	// Local reference to the "assert" object.
	var assert = CKEDITOR.test.assert;

	return {
		test_name : function()
		{
			assert.areSame( 'editor1', CKEDITOR.instances.editor1.name );
		},

		test_element : function()
		{
			assert.areSame( document.getElementById( 'editor1' ), CKEDITOR.instances.editor1.element.$ );
		},

		test_config : function()
		{
			// The instance default config must match the CKEDITOR.config.

			var config = CKEDITOR.instances.editor1.config;

			for ( var prop in CKEDITOR.config )
				assert.areSame( CKEDITOR.config[ prop ], config[ prop ], '"' + prop + '" doesn\'t match' );
		},

		test_config_inpage : function()
		{
			var self = this;

			CKEDITOR.replace( 'editor2',
				{
					// The custom setting to be checked.
					test1 : 'ball',
					baseHref : 'test',

					on :
					{
						instanceReady : function()
						{
							self.resume( function()
							{
								var config = CKEDITOR.instances.editor2.config;

								assert.areSame( 'ball', config.test1, '"test1" doesn\'t match' );
								assert.areSame( 'test', config.baseHref, '"baseHref" doesn\'t match' );

								// All other settings must match CKEDITOR.config.
								for ( var prop in CKEDITOR.config )
								{
									if ( prop != 'test1' && prop != 'baseHref' )
										assert.areSame( CKEDITOR.config[ prop ], config[ prop ], '"' + prop + '" doesn\'t match' );
								}
							} );
						}
					}
				});

			this.wait();
		},

		test_config_customConfig : function()
		{
			var testCase = this;

			CKEDITOR.on( 'instanceCreated', function( event )
				{
					if ( event.editor.name == 'editor3' )
					{
						event.editor.on( 'configLoaded', function()
							{
								testCase.resume( function()
								{
									var config = event.editor.config;

									assert.areSame( 'Ok', config.test_custom1, '"test_custom1" doesn\'t match' );
									assert.areSame( 'Ok', config.test_custom2, '"test_custom1" doesn\'t match' );
									assert.areSame( 'ball', config.test1, '"test1" doesn\'t match' );
									assert.areSame( 'test', config.baseHref, '"baseHref" doesn\'t match' );

									// All other settings must match CKEDITOR.config.
									for ( var prop in CKEDITOR.config )
									{
										if ( prop != 'customConfig' && prop != 'test_custom1' && prop != 'test_custom2' && prop != 'test1' && prop != 'baseHref' )
											assert.areSame( CKEDITOR.config[ prop ], config[ prop ], '"' + prop + '" doesn\'t match' );
									}
								});
							});
					}
				});

			// Pass in-page settings to the instance.
			CKEDITOR.replace( 'editor3', { customConfig : '_editor/custom_config_1.js', test1 : 'ball', baseHref : 'test' } );

			this.wait();
		},

		name : document.title
	};
})() );

	//]]>
	</script>
</head>
<body>
	<textarea id="editor1" class="ckeditor" cols="80" rows="10"></textarea>
	<textarea id="editor2" cols="80" rows="10"></textarea>
	<textarea id="editor3" cols="80" rows="10"></textarea>
</body>
</html>
